using System;
namespace ch.ethz.ssh2.packets
{
	
	/// <summary> PacketUserauthBanner.
	/// 
	/// </summary>
	/// <author>  Christian Plattner
	/// </author>
	/// <version>  2.50, 03/15/10
	/// </version>
	public class PacketUserauthFailure
	{
		virtual public System.String[] AuthThatCanContinue
		{
			get
			{
				return authThatCanContinue;
			}
			
		}
		virtual public bool PartialSuccess
		{
			get
			{
				return partialSuccess;
			}
			
		}
		internal byte[] payload;
		
		internal System.String[] authThatCanContinue;
		internal bool partialSuccess;
		
		public PacketUserauthFailure(System.String[] authThatCanContinue, bool partialSuccess)
		{
			this.authThatCanContinue = authThatCanContinue;
			this.partialSuccess = partialSuccess;
		}
		
		public PacketUserauthFailure(byte[] payload, int off, int len)
		{
			this.payload = new byte[len];
			Array.Copy(payload, off, this.payload, 0, len);
			
			TypesReader tr = new TypesReader(payload, off, len);
			
			int packet_type = tr.readByte();
			
			if (packet_type != Packets.SSH_MSG_USERAUTH_FAILURE)
				throw new System.IO.IOException("This is not a SSH_MSG_USERAUTH_FAILURE! (" + packet_type + ")");
			
			authThatCanContinue = tr.readNameList();
			partialSuccess = tr.readBoolean();
			
			if (tr.remain() != 0)
				throw new System.IO.IOException("Padding in SSH_MSG_USERAUTH_FAILURE packet!");
		}
	}
}